Skip to content

Conversation

@dmjb
Copy link
Member

@dmjb dmjb commented Jan 6, 2026

Prior to this PR, the edit API endpoint would not allow the proxy port to be reused. This was because the run config validation happened before stopping the old instance of the workload, and thus the port appeared to be still in use.

This PR adds some tweaks to the validation logic to allow port reuse for the edit case. It also tweaks the edit endpoint to reuse the previous port of the workload if a proxy port is not specified - this feels like a more natural behaviour than picking a new random port. This implementation also allows a new port to be selected if the caller desires.

There is a potential race condition in this implementation: if a new workload is created between the termination of the previous proxy process and the creation of the new one, it could potentially "steal" the port and cause the edit to fail after validation has completed. I think this is an acceptable risk for now - fixing it will require us to build some kind of locking mechanism for ports.

Fixes: #3182

@github-actions github-actions bot added size/XS Extra small PR: < 100 lines changed and removed size/XS Extra small PR: < 100 lines changed labels Jan 6, 2026
@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.18%. Comparing base (063ed3f) to head (163d8f9).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3200      +/-   ##
==========================================
+ Coverage   57.11%   57.18%   +0.07%     
==========================================
  Files         346      346              
  Lines       34314    34327      +13     
==========================================
+ Hits        19598    19631      +33     
+ Misses      13091    13061      -30     
- Partials     1625     1635      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

dmjb added 2 commits January 6, 2026 16:02
Prior to this PR, the edit API endpoint would not allow the proxy port
to be reused. This was because the run config validation happened before
stopping the old instance of the workload, and thus the port appeared to
be still in use.

This PR adds some tweaks to the validation logic to allow port reuse for
the edit case. It also tweaks the edit endpoint to reuse the previous
port of the workload if a proxy port is not specified - this feels like
a more natural behaviour than picking a new random port. This
implementation also allows a new port to be selected if the caller
desires.

There is a potential race condition in this implementation: if a new
workload is created between the termination of the previous proxy
process and the creation of the new one, it could potentially "steal"
the port and cause the edit to fail after validation has completed. I
think this is an acceptable risk for now - fixing it will require us to
build some kind of locking mechanism for ports.
@dmjb dmjb force-pushed the edit-api-port-reuse branch from 35de612 to 163d8f9 Compare January 6, 2026 16:02
@github-actions github-actions bot added size/M Medium PR: 300-599 lines changed and removed size/XS Extra small PR: < 100 lines changed labels Jan 6, 2026
@dmjb dmjb merged commit 755df51 into main Jan 7, 2026
36 checks passed
@dmjb dmjb deleted the edit-api-port-reuse branch January 7, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Medium PR: 300-599 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Workload edit endpoint fails when reusing same proxy_port

3 participants